package Application.Controller;

import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.scene.control.Slider;
import javafx.scene.control.ColorPicker;
import javafx.scene.control.ComboBox;
import Application.Tool.*;
import javafx.event.ActionEvent;

public class PenSettingsController {

    @FXML private Slider penSettingsSize;

    public ColorPicker getPenSettingsColor() {
        return penSettingsColor;
    }

    public ComboBox<String> getMaskSettings() {
        return this.penSettingsMask;
    }

    @FXML private ColorPicker penSettingsColor;
    @FXML private ComboBox<String> penSettingsMask;
    @FXML private Slider penSettingOpacity;

//    public void setColor(int r,int g,int b){
//        penSettingsColor.setValue(Color.rgb(r,g,b));
//    }

    @FXML public void onSizeChanged() {
        NormalPen.getInstance().setSize((int)penSettingsSize.getValue());
    }

    @FXML public void onColorChanged() {
        //NormalPen.getInstance().setColor(penSettingsColor.getValue());
        int r = (int)(penSettingsColor.getValue().getRed() * 255);
        int g = (int)(penSettingsColor.getValue().getGreen() * 255);
        int b = (int)(penSettingsColor.getValue().getBlue() * 255);
        //System.out.println(r);
        //System.out.println(g);
        //System.out.println(b);
        NormalPen.getInstance().setColor(255, r, g, b);
        System.out.print(penSettingsColor.getValue());
    }

    @FXML public void onOpacityChanged() {
        int opacity = (int)penSettingOpacity.getValue();
        NormalPen.getInstance().setOpacity(opacity);
    }

    @FXML public void onMaskChanged() {
        String maskName = penSettingsMask.getValue();

        NormalPen.getInstance().setMask(maskName);
    }

}
